"""
    使用 with 打开文件
"""


def open_file():

    # with的写法
    # with open('./static/test.txt', 'r', encoding='utf-8') as f:
    #     res = f.read()
    #     print(res)

    try:
        # 执行代码
        f = open('./static/test.txt', 'r', encoding='utf-8')
        res = f.read()
        print(res)
    except:
        # 解决异常
        pass
    finally:
        # 最终执行
        f.close()



if __name__ == '__main__':
    open_file()